<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of member_model
 *
 * @author phamtruong
 */
class member_model extends CI_Model {

    public function __construct() {
        parent::__construct();
    }

    //put your code here
    public function addmember($fullname, $email, $pass) {
        $fullname =  $this->db->escape_str($fullname);
        $email =  $this->db->escape_str($email);
        $pass =  $this->db->escape_str($pass);
        $sql_checkEmail = "SELECT id FROM member WHERE email=\"" . $email . "\"";
        $r = $this->db->query($sql_checkEmail);
        $r = $r->result_array();
        if (!isset($r))
            return -1;
        $this->db->query("INSERT INTO `capstone`.`member` (`email`, `fullname`, `password`) VALUES ('$email', '$fullname', md5('$pass'));");
        $id = $this->db->insert_id();
        if ($id)
            return $id;
        return 0;
    }

    public function getLogin($email, $pass) {
        $data = $this->db->query("SELECT * FROM `member` WHERE email=\"" . $email . "\" and password=md5(\"" . $pass . "\")");
        return $data->result_array();
    }

}

/* End of file member_model.php */
/* Location: ./application/models/member_model.php */